'\" t
.\"<!-- Copyright 1998 - 2009 Double Precision, Inc.  See COPYING for -->
.\"<!-- distribution information. -->
.\"     Title: mailbot
.\"    Author: Sam Varshavchik
.\" Generator: DocBook XSL Stylesheets v1.78.1 <http://docbook.sf.net/>
.\"      Date: 06/20/2015
.\"    Manual: Double Precision, Inc.
.\"    Source: Courier Mail Server
.\"  Language: English
.\"
.TH "MAILBOT" "1" "06/20/2015" "Courier Mail Server" "Double Precision, Inc\&."
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.\" http://bugs.debian.org/507673
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.ie \n(.g .ds Aq \(aq
.el       .ds Aq '
.\" -----------------------------------------------------------------
.\" * set default formatting
.\" -----------------------------------------------------------------
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
.ad l
.\" -----------------------------------------------------------------
.\" * MAIN CONTENT STARTS HERE *
.\" -----------------------------------------------------------------
.SH "NAME"
mailbot \- A MIME\-aware autoresponder utility
.SH "SYNOPSIS"
.HP \w'\fBmailbot\fR\ 'u
\fBmailbot\fR [options] {\fIprogram\fR} [arg...]
.PP
In
\&.mailfilter:
.sp
.nf
if (/^Subject: *info/)
{
     cc "| mailbot \-t /usr/share/autoresponse/info \-d autoresponsedb \e
            \-A \*(AqFrom: info@domain\&.com\*(Aq /usr/bin/sendmail \-f \*(Aq\*(Aq"
}
.fi
.SH "DESCRIPTION"
.PP
\fBmailbot\fR
reads an E\-mail message on standard input and creates an E\-mail message replying to the original message\*(Aqs sender\&. A
\fBprogram\fR
is specified as an argument to
\fBmailbot\fR
after all of
\fBmailbot\fR
options\&.
\fBprogram\fR
is expected to read the created autoreply on its standard input, and mail it\&. If
\fBprogram\fR
is not specified,
\fBmailbot\fR
runs \*(Aqsendmail \-f ""\*(Aq\&.
.PP
\fBmailbot\fR
has several options for suppressing duplicate autoresponse messages\&. If
\fBmailbot\fR
chooses not to send an autoresponse, it quietly terminates without running
\fBprogram\fR\&. The autoresponse is optionally formatted as a MIME delivery status notification\&.
.PP
The text of the autoresponse is specified by the
\fB\-t\fR
or the
\fB\-m\fR
argument\&. Either one is required\&. Everything else is optional\&. The only exception is the
\fB\-T replydraft\fR
option, which requires the
\fB\-l\fR
option instead of either
\fB\-t\fR
or
\fB\-m\fR\&. The default behavior is to send an autoresponse unless the original message has the "Precedence: junk" or the "Precedence: bulk" header, or the "Precedence: list" header, or the "List\-ID:" header, or if its MIME content type is "multipart/report" (this is the MIME content type for delivery status notifications)\&. The
\fB\-M\fR
option formats the the autoresponse itself as a MIME delivery status notification\&.
.SH "OPTIONS"
.PP
\-A "\fIheader: value\fR"
.RS 4
Add a header to the autoresponse\&. Multiple
\fB\-A\fR
options are allowed\&. In most situations, the
\fB\-A\fR
option must be used to set the
\(lqFrom:\(rq
header in the autogenerated response\&.
.RE
.PP
\-f\fIaddress\fR
.RS 4
Address the autoresponse to
\fIaddress\fR, which must be an
\m[blue]\fBRFC 2822\fR\m[]\&\s-2\u[1]\d\s+2
address\&. By default
\fBmailbot\fR
takes the autoresponse address from the
From:
(or the
Reply\-To:) header in the original message\&.
\fB\-f\fR, if present, overrides and explicitly sets the autoresponse address\&. "\fIaddress\fR" must immediately follow the
\fB\-f\fR
option without an intervening space (it\*(Aqs a single command line argument)\&. An
\fB\-f\fR
option without an
\fIaddress\fR
takes the address from the
\fBSENDER\fR
environment variable\&.
.RE
.PP
\-t \fIfilename\fR
.RS 4
Read text autoresponse from
\fIfilename\fR, which must contain a plain text message in
\(lqflowed\-text\(rq
format\&. In a
\(lqflowed\-text\(rq\-formatted message, each line that ends with a space character indicates that the line logically flows into the next line\&. This allows the message to be reformatted for any shown display width\&.
.if n \{\
.sp
.\}
.RS 4
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
.ps +1
\fBNote\fR
.ps -1
.br
Messages in languages (see the
\fB\-c\fR
option) which use spaces as word delimiters must have
\fItwo\fR
spaces at the end of a flowed line\&. The last space on a flowed line is logically removed, and the first space separates the last word on the previous line from the first word on the next line\&. Otherwise, the two words will not have a logical space between them if they get repositioned as part of adjusting the message\*(Aqs width for display\&.
.sp
Messages in ideographic languages that do not use spaces as word delimiters need only one space trailing a flowed line\&.
.sp .5v
.RE
.if n \{\
.sp
.\}
.RS 4
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
.ps +1
\fBNote\fR
.ps -1
.br
The trailing whitespace has no visual impact when shown by software that does not implemented flowed text format, and always displays messages using their original width\&.
.sp .5v
.RE
.RE
.PP
\-c \fIcharset\fR
.RS 4
Set the autoresponse\*(Aqs MIME character set to
\fIcharset\fR\&. Run
\fBmailbot\fR
without any arguments to see the default character set\&.
.RE
.PP
\-m \fIfilename\fR
.RS 4
Read a MIME autoresponse from
filename\&. This is similar to the
\fB\-t\fR
option, except that
\fIfilename\fR
contains MIME headers, followed by a blank line, and the corresponding MIME content\&. The contents of
\fIfilename\fR
are inserted in the autoresponse without further processing\&.
.sp
The specified file must contain the
\(lqContent\-Type\(rq
header specifying the
\(lqtext/plain\(rq
MIME type, with the
\(lqformat=flowed\(rq,
\(lqdelsp=yes\(rq, and the
\(lqcharset\(rq
attributes, which override the
\fB\-c\fR
parameter\&. If the specified file has a
\(lqContent\-Transfer\-Encoding\(rq
header it must be either
\(lq7bit\(rq
or
\(lq8bit\(rq, it may not be
\(lqquoted\-printable\(rq\&.
\fBmailbot\fR
always drops any existing
\(lqContent\-Transfer\-Encoding\(rq
header and always adds the
\(lqContent\-Transfer\-Encoding: 8bit\(rq
header, even with the
\fB\-m\fR, since the salutation inserted into the message includes the sender\*(Aqs name, which may contain 8\-bit characters\&. Example:
.sp
.if n \{\
.RS 4
.\}
.nf
Content\-Type: text/plain; format=flowed; delsp=yes; charset="iso\-8859\-1"

Mary had a little lamb,  
Its fleece was white as snow\&.  
And everywhere Mary went,  
The lamb was sure to go\&.
.fi
.if n \{\
.RE
.\}
.if n \{\
.sp
.\}
.RS 4
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
.ps +1
\fBNote\fR
.ps -1
.br
When the
\fB\-m\fR
option is specified
\fBmailbot\fR
ignores the locale\*(Aqs character set and formats the autoreply according to the character set read from the
\(lqContent\-Type\(rq
header\&.
.sp .5v
.RE
.RE
.PP
\-M \fIaddress\fR
.RS 4
Format the autoresponse as a delivery status notification (\m[blue]\fBRFC 1894\fR\m[]\&\s-2\u[2]\d\s+2)\&.
\fIaddress\fR
is an
\m[blue]\fBRFC 2822\fR\m[]\&\s-2\u[1]\d\s+2
E\-mail address that generates the DSN\&. Note that the
\fB\-A\fR
option should still be used in addition to
\fB\-M\fR
in order to set the
From:
header on the autoresponse\&.
\fB\-M\fR
sets the DSN address only\&. The
\fB\-M\fR
option automatically sets
\fB\-T \fR\fBreplydsn\fR
.RE
.PP
\-R \fItype\fR
.RS 4
Specify the feedback report type, with
\fItype\fR
set to
abuse,
fraud,
other, or
virus\&. Must be used together with
\(lq\-T feedback\(rq
or
\(lq\-T replyfeedback\(rq\&.
.RE
.PP
\-T \fIformat\fR
.RS 4
Set the reply format\&.
\fIformat\fR
must be one of the following values:
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\(lqreply\(rq
\- the default reply format\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\(lqreplyall\(rq
\- like
\(lqreply\(rq, except also puts the recipients in the original message\*(Aqs
\(lqTo:\(rq
and
\(lqCc:\(rq
headers into the
\(lqCc:\(rq
header of the generated reply\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\(lqreplydsn\(rq
\- like
\(lqreply\(rq, except the message is formatted as a delivery status notification\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\(lqreplydraft\(rq
\- like
\(lqreply\(rq, with the text of the autoresponse coming from a maildir specified by the
\fB\-l\fR
option\&. See
\(lqAutoreplies from a maildir folder\(rq, below\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\(lqforward\(rq
\- attach the original message as forwarded text\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\(lqforwardatt\(rq
\- attach the original message as a forwarded message attachment\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\(lqfeedback\(rq
\- generate an Email Feedback Report message (see
\m[blue]\fBRFC 5965\fR\m[]\&\s-2\u[3]\d\s+2)\&. The
\(lq\-R\(rq
option is required when this is specified\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\(lqreplyfeedback\(rq
\- like
\(lqfeedback\(rq, but also adds a
\(lqTo:\(rq
header, addressed to the original message\*(Aqs sender\&.
.RE
.RE
.PP
\-N
.RS 4
Do not quote the contents of the original message in the message created by
\(lqreply\(rq,
\(lqreplyall\(rq,
\(lqreplydsn\(rq,
\(lqfeedback\(rq, and
\(lqreplyfeedback\(rq
options\&.
.if n \{\
.sp
.\}
.RS 4
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
.ps +1
\fBNote\fR
.ps -1
.br
The original message gets quoted, in the absence of this option, only if the original message was formatted as plain text\&.
\fBmailbot\fR
is unable to quote an original message which was formatted as
HTML, or any other non\-plaintext format\&.
.sp .5v
.RE
.if n \{\
.sp
.\}
.RS 4
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
.ps +1
\fBNote\fR
.ps -1
.br
For
\(lqreplydsn\(rq,
\(lqfeedback\(rq, and
\(lqreplyfeedback\(rq
options, the convention is to attach the original message, or only its headers, separately; so this option should always be specified for these three reply formats\&.
.sp .5v
.RE
.RE
.PP
\-a
.RS 4
Attach the entire message, for
\(lqreplydsn\(rq,
\(lqfeedback\(rq, and
\(lqreplyfeedback\(rq, instead of only its headers\&.
.RE
.PP
\-e
.RS 4
Generate a reply (\(lqreply\(rq\-formats) to the address listed in any
\(lqErrors\-To\(rq
or
\(lqReturn\-Path\(rq
header, if present, instead of the
\(lqFrom\(rq
header\&.
.RE
.PP
\-S \(lqsalutation\(rq
.RS 4
Use the given
\fIsalutation\fR
in the
\(lqreply\(rq\&. The default value is
\(lq%F writes:\(rq\&. The following substitutions are recognized in the salutation string:
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
%%
\- an explicit
%
character\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
%n
\- a newline character\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
%C
\- the
\(lqX\-Newsgroup:\(rq
header from the original message\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
%N
\- the
\(lqNewsgroups:\(rq
header from the original message\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
%i
\- the
\(lqMessage\-ID:\(rq
header from the original message\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
%f
\- the original message\*(Aqs sender\*(Aqs address\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
%F
\- the original message\*(Aqs sender\*(Aqs name\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
%S
\- the
\(lqSubject:\(rq
header from the original message
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
%d
\- the original message\*(Aqs date, in the local timezone\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
%{\fI\&.\&.\&.\fR}d
\- use
\fBstrftime\fR() to format the original message\*(Aqs date\&. A plain
%d
is equivalent to
%{%a, %d %b %Y %H:%M:%S %z}d\&.
.RE
.sp
All other characters in the salutation string are left as is\&.
.RE
.PP
\-F \(lqmarker\(rq
.RS 4
When generating a
forward, use the
\fImarker\fR
to separate the forwarded message from the autoreply text, instead of the default
\(lq\-\-\- Forwarded message \-\-\-\(rq
.RE
.PP
\-r \fIaddrlist\fR
.RS 4
\fIaddrlist\fR
is a comma\-separated list of
\m[blue]\fBRFC 2822\fR\m[]\&\s-2\u[1]\d\s+2
E\-mail addresses\&.
\fBmailbot\fR
sends an autoresponse only if the original message has at least one of the specified addresses in any
To:
or
Cc:
header\&.
.RE
.PP
\-d \fIfilename\fR
.RS 4
Create a small database,
\fIfilename\fR, that keeps track of senders\*(Aq E\-mail addresses, and prevent duplicate autoresponses going to the same address (suppress autoresponses going back to the same senders, for subsequent received messages)\&. The
\fB\-d\fR
option is only available if
\fBmaildrop\fR
has GDBM/DB extensions enabled\&.
.RE
.PP
\-D \fIx\fR
.RS 4
Do not send duplicate autoresponses (see the
\fB\-d\fR
option) for at least
\fIx\fR
days (default: 1 day)\&. The
\fB\-d\fR
option creates a database of E\-mail addresses and the times an autoresponse was last mailed to them\&. Another autoresponse to the same address will not be mailed until at least the amount of time specified by the
\fB\-D\fR
option has elapsed\&.
.RE
.PP
\-s "\fIsubject\fR"
.RS 4
Set the
Subject:
header on the autoresponse to
\fIsubject\fR\&.
.RE
.PP
\-n
.RS 4
Show the resulting message, do not send it\&. Used for debugging purposes\&.
.RE
.PP
\-\-feedback\-original\-envelope\-id\ \&\fI"<envelopeid>"\fR, \-\-feedback\-original\-mail\-from\ \&\fI"<mailfrom>"\fR, \-\-feedback\-reporting\-mta\ \&"\fIdns;\ \&hostname"\fR, \-\-feedback\-source\-ip\ \&\fIaaa\&.bbb\&.ccc\&.ddd\fR, \-\-feedback\-incidents\ \&\fIn\fR, \-\-feedback\-authentication\-results\ \&\fI"results"\fR, \-\-feedback\-original\-rcpt\-to\ \&\fI"<rcptto>"\fR, \-\-feedback\-reported\-domain\ \&\fIexample\&.com\fR
.RS 4
Optional parameters to include in the feedback report generated by
\(lqfeedback\(rq
and
\(lqreplyfeedback\(rq\&.
\fBmailbot\fR
always adds
\(lqArrival\-Date\(rq
with the current time, as well as
\(lqVersion\(rq
and
\(lqUser\-Agent\(rq\&.
.sp
\(lq\-\-feedback\-authentication\-results\(rq,
\(lq\-\-feedback\-original\-rcpt\-to\(rq
and
\(lq\-\-feedback\-reported\-domain\(rq
may be specified more than once\&.
.RE
.PP
\-l \fImaildir\fR
.RS 4
Specifies the maildir for the
\(lq\-T replydraft\(rq
option\&. See
\(lqAutoreplies from a maildir folder\(rq, below\&.
.RE
.SS "Autoreplies from a maildir folder"
.PP
In
\&.mailfilter:
.sp
.if n \{\
.RS 4
.\}
.nf
cc "| mailbot \-T replydraft \-l \*(Aq\&./Maildir/\&.Vacation\*(Aq \e
        \-d autoresponsedb \e
        \-A \*(AqFrom: info@domain\&.com\*(Aq /usr/bin/sendmail \-f \*(Aq\*(Aq"
to "\&./Maildir"
.fi
.if n \{\
.RE
.\}
.PP
The
\fB\-T replydraft\fR
reply format takes the content of the autoresponse from the most recent message in a maildir\&. The
\fB\-l\fR
option specifies the maildir\&. The above example takes the message from
$HOME/Maildir/\&.Drafts
which should be a maildir (with the usual
cur,
new, and
tmp
subdirectories)\&. It would typically get created by Courier\-IMAP as a folder named
\(lqVacation\(rq\&.
.PP
This makes it possible to install autoreplies via an IMAP client by creating a folder named
\(lqVacation\(rq, and copying a message into it\&. The contents of the message become the autoresponse\&.
.PP
If the named maildir does not exist, or is empty,
\fBmailbot\fR
does nothing\&. If the named maildir has more than one message, the most recent message gets used\&.
.PP
The above example uses additional
\fBmailbot\fR
options to suppress duplicate autoresponses, and to set the
\(lqFrom:\(rq
header on the autoresponse\&.
.SH "SEE ALSO"
.PP
\m[blue]\fB\fBmaildrop\fR(1)\fR\m[]\&\s-2\u[4]\d\s+2,
\m[blue]\fB\fBreformail\fR(1)\fR\m[]\&\s-2\u[5]\d\s+2,
\m[blue]\fB\fBreformime\fR(1)\fR\m[]\&\s-2\u[6]\d\s+2\&.
.SH "AUTHOR"
.PP
\fBSam Varshavchik\fR
.RS 4
Author
.RE
.SH "NOTES"
.IP " 1." 4
RFC 2822
.RS 4
\%http://tools.ietf.org/html/rfc2822
.RE
.IP " 2." 4
RFC 1894
.RS 4
\%http://tools.ietf.org/html/rfc1894
.RE
.IP " 3." 4
RFC 5965
.RS 4
\%http://tools.ietf.org/html/rfc5965
.RE
.IP " 4." 4
\fBmaildrop\fR(1)
.RS 4
\%http://www.courier-mta.org/maildrop/maildrop.html
.RE
.IP " 5." 4
\fBreformail\fR(1)
.RS 4
\%http://www.courier-mta.org/maildrop/reformail.html
.RE
.IP " 6." 4
\fBreformime\fR(1)
.RS 4
\%http://www.courier-mta.org/maildrop/reformime.html
.RE
